﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDay.iCal;
using DDay.iCal.Components;
using DataTransferObject;
using Engine.TaskVerification;
using Engine.TaskPrioritizeAlgo;
using Engine.ScheduleAlgo;
using System.Windows.Forms;

namespace Engine
{
    /// <summary>
    /// 
    /// </summary>
    public abstract class JskeAlgorithm
    {
        #region Attributes
        protected TaskList _taskList;
        protected iCalendar _iCal;
        protected FreeTimeList freeTimeList;
        protected MappedFreeTimeList mappedFreeTimeList;
        protected SystemConfiguration systemConfiguration;
        protected IPrioritizeAlgorithm _PrioritizeTaskList;
        protected IScheduleAlgorithm _ScheduleTaskList;
        protected IVerifyTasksConstraint _VerifyTaskConstraint;
        private PrioritizeReport priorityReport;
        private ScheduleReport schedulReport;
        private ConstraintViolation constraintViolate;

        #endregion

        #region Properties
        public ConstraintViolation ConstraintViolate
        {
            get { return constraintViolate; }
            set { constraintViolate = value; }
        }

        public ScheduleReport ScheduReport
        {
            get { return schedulReport; }
            set { schedulReport = value; }
        }

        public PrioritizeReport PriorityReport
        {
            get { return priorityReport; }
            set { priorityReport = value; }
        }

        #endregion

        #region Methods
        /*
         * Sử dụng Template method pattern cho giải thuật
         */
        /// <summary>
        /// Runs this instance.
        /// </summary>
        /// <returns></returns>
        public abstract List<Event> run();
        //{
        //    /*
        //     * Các bước thực hiện giải thuật:
        //     * 1/ kiểm tra constraint
        //     * 2/ thiết lập priority
        //     * 3/ trả về chuỗi Event đã được schedule
        //    */ 
        //    //verifyTaskConstraint();
        //    ////setPriorityTaskList();
        //    //return scheduleTaskList();
        //}

        /// <summary>
        /// Verifies the task constraint.
        /// </summary>
        /// <returns></returns>
        protected abstract ConstraintViolation verifyTaskConstraint();

        /// <summary>
        /// Sets the priority task list.
        /// </summary>
        /// <returns></returns>
        protected abstract PrioritizeReport setPriorityTaskList();

        /// <summary>
        /// Schedules the task list.
        /// </summary>
        /// <returns></returns>
        protected abstract List<Event> scheduleTaskList();

        public abstract void setProgressBar(ProgressBar p);

        public abstract void updateProgressBar(ProgressBar p, int val);
        #endregion

    }
}
